#include "AccountManager.h"

AccountManager::AccountManager(): instance(0)
{
	instance = new AccountManagerInstance();
}

AccountManager::AccountManager(const AccountManager& rhs): instance(rhs.instance)
{
	if (instance)
		instance->IncreaseReference();
}

AccountManager::~AccountManager()
{
	if (instance)
	{
		instance->DecreaseReference();

		if (instance->GetReferenceCount() == 0)
		{
			delete instance;
		}

		instance = 0;
	}
}

void AccountManager::AddAccount(const Account& account)
{
	if (instance)
		instance->AddAccount(account);
}

const Account* AccountManager::GetAccount(const std::string& username) const
{
	if (instance)
		return instance->GetAccount(username);
	else
		return 0;
}


